//
//  TextTableViewCell.m
//  YaoHeAPP
//
//  Created by mac on 15/12/19.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "TextTableViewCell.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"

#import "UIView+HY.h"

#define lFont [UIFont systemFontOfSize:14]
#define tColor [UIColor darkGrayColor]
@implementation TextTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier ];
    if (self) {
        
        //是否是推荐的（是推荐的要展示一张图片）
        _tui_jian=[UIImageView new];
        [self addSubview:_tui_jian];
        [_tui_jian mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(0);make.left.offset(0);
            make.height.offset(36);make.width.offset(36);
        }];
        
        //发布报价的用户头像
        _headImage=[UIImageView new];
        //_headImage.backgroundColor=[UIColor grayColor];
        _headImage.layer.masksToBounds=YES;
        _headImage.layer.cornerRadius=24;
        [self addSubview:_headImage];
        [_headImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.mas_centerY).offset(-2);
            make.left.offset(25);  make.width.offset(48);  make.height.offset(48);
        }];
        
        //评分的显示
        _start=[UILabel new];
        //_start.backgroundColor=[UIColor yellowColor];
        _start.textColor=[UIColor orangeColor];
        [self addSubview:_start];
        [_start mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_headImage.mas_bottom).offset(4);
            make.height.offset(18);
            make.centerX.equalTo(_headImage.mas_centerX).offset(0);
            make.width.offset(74);
        }];
        
        //添加到黑名单按钮
        _btnBN=[UIButton new];
        _btnBN.titleLabel.font=lFont;
        [_btnBN setTitleColor:[UIColor colorWithRed:28.f/255.f green:52.f/255.f blue:137.f/255.f alpha:1] forState:UIControlStateNormal];
        [self addSubview:_btnBN];
        [_btnBN mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_headImage.mas_centerX).offset(0);
            make.top.equalTo(_start.mas_bottom).offset(5);
            make.height.offset(20);
            make.width.offset(80);
        }];
        
        //竖条图片
        _bgImage=[UIImageView new];
        _bgImage.backgroundColor=[UIColor grayColor];
        [self addSubview:_bgImage];
//        [_bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(15);  make.left.equalTo(_btnBN.mas_right).offset(2);
//            make.width.offset(1); make.bottom.offset(-15);
//        }];
        
        
        //报价标签
        _bao_jiaL=[UILabel new];
        _bao_jiaL.text=@"报   价:";
        _bao_jiaL.font=lFont;
        //_baojiaMesage.textColor=tColor;
        [self addSubview:_bao_jiaL];
//        [_bao_jiaL mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(15); make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(20); make.width.offset(50);
//        }];
        
        _bao_jiaL.frame=CGRectMake(110, 15, 50, 20);
        
        
        //报价信息
        _baojiaMesage=[UILabel new];
        _baojiaMesage.font=lFont;
        _baojiaMesage.textColor=[UIColor orangeColor];
        [self addSubview:_baojiaMesage];
//        [_baojiaMesage mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(15);  make.left.equalTo(_bao_jiaL.mas_right).offset(1);
//            make.height.offset(20);  make.right.offset(-5);
//        }];
        
        _baojiaMesage.frame=CGRectMake(_bao_jiaL.right+2, 15, self.right-5, 20);
        
        //交易员标签
        _jiao_yi=[UILabel new];
        _jiao_yi.text=@"交易员:";
        _jiao_yi.font=lFont;
        [self addSubview:_jiao_yi];
//        [_jiao_yi mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(50);  make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(20); make.width.offset(50);
//        }];
        _jiao_yi.frame=CGRectMake(110, _bao_jiaL.bottom+5, 50, 20);
        
        
        
        //交易人名
        _name=[UILabel new];
        _name.font=lFont;
        [self addSubview:_name];
//        [_name mas_remakeConstraints:^(MASConstraintMaker *make){
//            make.top.offset(50); make.left.equalTo(_jiao_yi.mas_right).offset(1);
//            make.height.offset(20);   make.width.offset(60);
//        }];
        
        _name.frame=CGRectMake(_jiao_yi.right+2, _bao_jiaL.bottom+5, 50, 20);
        
        
        //电话号码
        _phoneNum=[UIButton new];
        _phoneNum.titleLabel.font=lFont;
        //_phoneNum.backgroundColor=[UIColor yellowColor];
        [_phoneNum setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        [self addSubview:_phoneNum];
//        [_phoneNum mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(50); make.left.equalTo(_name.mas_right).offset(1);
//            make.height.offset(20); make.width.offset(100);
//        }];
        
        _phoneNum.frame=CGRectMake(_name.right+2, _bao_jiaL.bottom+5, 110, 20);
        
        
        //备注标签
        _remarkL=[UILabel new];
        _remarkL.text=@"备   注:";
        _remarkL.font=lFont;
        [self addSubview:_remarkL];
//        [_remarkL mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.offset(85);  make.left.equalTo(_bgImage.mas_right).offset(10);
//            make.height.offset(15); make.width.offset(50);
//        }];
        
        _remarkL.frame=CGRectMake(110, _jiao_yi.bottom+5, 50, 20);
        
        //备注信息内容显示
        _textMsg=[[UILabel alloc]init];
        _textMsg.numberOfLines=0;
        _textMsg.textAlignment = NSTextAlignmentLeft;
        _textMsg.font=lFont;
        [self addSubview:_textMsg];
//        [_textMsg mas_makeConstraints:^(MASConstraintMaker *make) {
//         make.left.equalTo(_remarkL.mas_right).offset(2);
//         make.right.offset(-5);
//         make.top.offset(85);
//         make.height.offset([_textMsg.text  boundingRectWithSize: CGSizeMake(_textMsg.frame.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:_textMsg.font ,NSFontAttributeName, nil] context:nil].size.height);
//         }];
        
    }
    return self;
    
}




/*- (void)awakeFromNib {
    
    _headImage.layer.masksToBounds=YES;
    _headImage.layer.cornerRadius=23;
    
}*/

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
